package com.ds.extend.aware;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

@Component
public class ResourceLoaderAwareTest  implements ResourceLoaderAware {
    @Autowired
    private ResourceLoader resourceLoader;


    public void showResourceData() throws IOException
    {
        //This line will be changed for all versions of other examples
//        Resource banner = resourceLoader.getResource("file:D:\\xx\\cloudtest\\data-server2\\src\\main\\resources\\application.properties");
//
//        InputStream in = banner.getInputStream();
//
//        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//
//        while (true) {
//            String line = reader.readLine();
//            if (line == null) {
//                break;
//            }
//            System.out.println(line);
//        }
//        reader.close();
    }

    @Override
    public void setResourceLoader(ResourceLoader resourceLoader) {
        try {
            showResourceData();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
